package com.example.kehoobackend.controller;

import com.example.kehoobackend.FaceIdentity.FaceAdd;
import com.example.kehoobackend.FaceIdentity.FaceSearch;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@CrossOrigin
public class FaceController {

    @RequestMapping("/faceRegister")
    @ResponseBody
    public String FaceRegister(HttpServletRequest request, HttpServletResponse response){
        response.addHeader("Access-Allow-Control-Origin","*");
        String image = request.getParameter("base");
        String user_id = request.getParameter("id");
        System.out.println(image);
        String result = FaceAdd.add(image,user_id);
        return result;
    }

    @RequestMapping("/faceLogin")
    @ResponseBody
    public String FaceLogin(HttpServletRequest request, HttpServletResponse response){
        response.addHeader("Access-Allow-Control-Origin","*");
        String image = request.getParameter("base");
        String result = FaceSearch.faceSearch(image);
        return result;
    }
}

